package com.situ.dao.impl;

import com.situ.common.Global;
import com.situ.dao.UserDao;
import com.situ.pojo.Student;
import com.situ.pojo.User;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class UserDaoImpl implements UserDao {
    private BeanPropertyRowMapper<User> rowMapper = new BeanPropertyRowMapper<>(User.class);
    @Override
    public User findByUsername(String username) {
        JdbcTemplate jdbcTemplate = Global.getJdbcTemplate();
        try {
            String sql = "select id,username,password from t_security_user where username = ?";
            // 返回结果 如果查询不到则返回空
            return jdbcTemplate.queryForObject(sql, rowMapper, username);
        }catch (Exception e){
            return null;
        }

    }
}
